<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef MP-WEIXIN
			console.log("微信用户信息！")
			getOpenId();
			// #endif
			console.log("用户信息！")
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}

	function getOpenId(e) {
		const shareUserId = uni.getStorageSync('ShareUserId')
		uni.login({
			success(res) {
				if (res.code) {
					//发起网络请求
					uni.request({
						url: 'https://min.erkantv.cn:443/portal/openId/ikran',
						method: "POST",
						header: {
							'content-type': 'application/json' // 默认值
						},
						data: {
							code: res.code,
							shareUserId: shareUserId
						},
						success: (rec) => {
							var user = rec.data;
							console.log('循环循环过来的', user);
							uni.removeStorageSync('user')
							uni.setStorageSync("user", user);
							// 问题持续时间
							//获取创建时间
							let createTime = new Date(user.statusCreate).getTime();
							// console.log("创建时间{}", createTime);
							//获取当前时间
							let now = new Date().getTime();
							// console.log("当前时间{}", now);
							//计算时间差
							let time = createTime - now;
							console.log("时间差{}", time);
							if (time < 0) {
								uni.request({
									url: 'https://min.erkantv.cn:443/portal/openId/deleteStatus',
									method: "GET",
									header: {
										'content-type': 'application/json' // 默认值
									},
									data: {
										id: user.id,
										status: 0
									},
									success: (rec) => {
										console.log("会员身份变更!");
									}
								})
							}

						}
					})
				} else {
					console.log('登录失败！' + res.errMsg)
				}
			}
		})
	}
</script>


<style lang="scss">
	/*每个页面公共css */
	page {
		background: #000000;
		color: #fff;
	}

	swiper-item ::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
		display: none;
	}
</style>